﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IPIdee.MapServices.Client.Entities.Coordinates
{
    public class AbsMapSpotCoordinate
    {
        public AbsMapSpotCoordinate(int absX, int absY, int zoom)
        {
            this.AbsX = absX;
            this.AbsY = absY;
            this.Zoom = zoom;
        }

        public int AbsX
        {
            get;
            set;
        }

        public int AbsY
        {
            get;
            set;
        }

        public int Zoom
        {
            get;
            set;
        }

        public static implicit operator LatLngCoordinate(AbsMapSpotCoordinate sourceCoordinate)
        {
            var latitude = CoordinateConvertor.GetLatitudeByAbsoluteYOnZoom(sourceCoordinate.AbsY, sourceCoordinate.Zoom);
            var longitude = CoordinateConvertor.GetLongitudeByAbsoluteXOnZoom(sourceCoordinate.AbsX, sourceCoordinate.Zoom);
            var result = new LatLngCoordinate(latitude, longitude, sourceCoordinate.Zoom);

            return result;
        }
    }
}
